# get the command arguments from perl
# rsm number
# runfolder
# run number

args=(commandArgs(TRUE))

for(i in 1:length(args)){
    eval(parse(text=args[[i]]))
}	 

#run <- 1
#runfolder <- "/home/rumen/simulation1/K=1_P=1_MU=1e-06_NU=1e-05_RSM=1_B=0.02_D=0.016_NN=100_T=7300_H=300_W=300"

#divlimit <- 0.2
dlog <-  read.csv(paste(runfolder,"/rep",run,".divergence.biopsy.sampling.locations.log",sep=""),header=FALSE)

mainlab <- strsplit(runfolder, "/")[[1]][5]

pdf(paste(runfolder,"/rep",run,"_divergence_plot.pdf",sep=""),width=6,height=6)
par(pty="s")
#par(mar=c(3,3,3,1))
divlimit <- max(dlog[,5])*1.2
plot(round(dlog[,1]/365),dlog[,5],xlab=NA,ylab=NA,t="l",ylim=c(0,divlimit),xlim=c(0,round(max(dlog[,1])/365)),col="black")
mtext("Divergence", side=2, line = 2)
mtext("Time (years)", side=1, line = 2)
title(mainlab,cex.main=0.7)
dev.off()





